package org.jeecg.modules.health_records.health_anal.service.impl;

import org.jeecg.modules.health_records.health_abdophy.mapper.HealthAbdoPhyInfoMapper;
import org.jeecg.modules.health_records.health_anal.entity.HealthAnalRectumInfo;
import org.jeecg.modules.health_records.health_anal.mapper.HealthAnalRectumInfoMapper;
import org.jeecg.modules.health_records.health_anal.service.IHealthAnalRectumInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Description: 现病史-体格检查-肛门与直肠检查
 * @Author: jeecg-boot
 * @Date:   2025-06-25
 * @Version: V1.0
 */
@Service
public class HealthAnalRectumInfoServiceImpl extends ServiceImpl<HealthAnalRectumInfoMapper, HealthAnalRectumInfo> implements IHealthAnalRectumInfoService {
    @Autowired
    private HealthAnalRectumInfoMapper healthAnalRectumInfoMapper;
    /**按recordid查询**/
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<HealthAnalRectumInfo> queryByRecordId(HealthAnalRectumInfo healthAnalRectumInfo) {
        return healthAnalRectumInfoMapper.queryByRecordId(Long.valueOf(healthAnalRectumInfo.getRecordid()),healthAnalRectumInfo.getIdNumber());

    }
    /**电子病历信息查询接口（查询时间最新的那条数据）--按recordid查询**/
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<HealthAnalRectumInfo> queryElecRecord(HealthAnalRectumInfo healthAnalRectumInfo){

        return healthAnalRectumInfoMapper.queryElecRecord(Long.valueOf(healthAnalRectumInfo.getRecordid()),healthAnalRectumInfo.getIdNumber());

    }
    //新规则查询当下时间往前12个月的就诊数据作为电子病历数据
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<HealthAnalRectumInfo> newQueryElecRecord(HealthAnalRectumInfo healthAnalRectumInfo) {
        return healthAnalRectumInfoMapper.newQueryElecRecord(Long.valueOf(healthAnalRectumInfo.getRecordid()),healthAnalRectumInfo.getSeeId(),healthAnalRectumInfo.getIdNumber());

    }

    //新规则：除去当下时间往前12个月的就诊数据，剩下的数据为既往病历数据
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<HealthAnalRectumInfo> newQueryPastRecord(HealthAnalRectumInfo healthAnalRectumInfo) {
        return healthAnalRectumInfoMapper.newQueryPastRecord(Long.valueOf(healthAnalRectumInfo.getRecordid()),healthAnalRectumInfo.getSeeId(),healthAnalRectumInfo.getIdNumber());

    }
}
